package com.itheima.JDBC.demo;

import com.mysql.jdbc.Driver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class demo03 {
    public static void main(String[] args) throws Exception {
        String url = "jdbc:mysql:///heima";
        String username = "root";
        String password = "root";
        String sql = "select *from emp";
        Class.forName("com.mysql.jdbc.Driver");
        final Connection connection = DriverManager.getConnection(url, username, password);
        final Statement statement = connection.createStatement();
        final ResultSet resultSet = statement.executeQuery(sql);
        while (resultSet.next()) {
            System.out.println(resultSet.getString("ename"));
        }
        resultSet.close();
        statement.close();
        connection.close();
    }
}
